package io.github.betacat.sinluo;

import io.github.betacat.sinluo.config.ExecBot;
import jakarta.annotation.Resource;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.telegram.telegrambots.bots.DefaultBotOptions;
import org.telegram.telegrambots.meta.TelegramBotsApi;
import org.telegram.telegrambots.meta.exceptions.TelegramApiException;
import org.telegram.telegrambots.updatesreceivers.DefaultBotSession;

@SpringBootApplication
public class SinluoBotApplication implements CommandLineRunner {

    @Resource
    private ExecBot execBot;

    public static void main(String[] args) {
        SpringApplication.run(SinluoBotApplication.class, args);
    }

    @Override
    public void run(String... args) {
        try {
            TelegramBotsApi telegramBotsApi = new TelegramBotsApi(DefaultBotSession.class);
            telegramBotsApi.registerBot(execBot);
        } catch (TelegramApiException e) {
            e.printStackTrace();
        }
    }
}
